package org.ssp.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ssp.dao.ApplyStepDao;
import org.ssp.dao.PartJobDao;
import org.ssp.dao.SchoolDao;
import org.ssp.dao.StudyDao;
import org.ssp.dao.VisaDao;
import org.ssp.impl.ApplyStepImpl;
import org.ssp.impl.PartJobImpl;
import org.ssp.impl.SchoolImpl;
import org.ssp.impl.StudyImpl;
import org.ssp.impl.VisaImpl;
import org.ssp.pojo.ApplyStep;
import org.ssp.pojo.PartJob;
import org.ssp.pojo.School;
import org.ssp.pojo.Study;
import org.ssp.pojo.Visa;
import org.ssp.util.ExcelUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor;

/**
 * 
 */
@WebServlet("/study")
public class StudyServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String method=request.getParameter("method");
		/*if(request.getSession().getAttribute("assist")==null){
			response.sendRedirect(request.getContextPath());
			return;
		}*/
		if("page".equals(method)){//1,请求会员中心page
			System.out.println("study....page....");
			request.getRequestDispatcher("/WEB-INF/page/admin/study.jsp").forward(request, response);
		}else if("list".equals(method)){
			System.out.println("study....list.....");//2,学校列表
			int page=Integer.valueOf(request.getParameter("page"));
			int rows=Integer.valueOf(request.getParameter("rows"));
			int offset=(page-1)*rows;
			int total=0;
			SchoolDao sd=new SchoolImpl();
			ArrayList<School> list=sd.findAll(offset, rows);
			total=sd.findAll();
			JSONObject json=new JSONObject();
			json.element("rows", list);
			json.element("total", total);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}else if("list10".equals(method)){
			System.out.println("list10");
			int rows=10;
			int offset=0;
			StudyDao sd=new StudyImpl();
			ArrayList<Study> list=sd.find10(offset,rows);
			
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			JSONObject json=new JSONObject();
			json.element("total", 10);
		    json.element("rows", JSONArray.fromObject(list,jsonConfig));
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}/*else if("addschool".equals(method)){//3,批量导入大学
			System.out.println("study....addschool.....");
			String root = this.getServletContext().getRealPath("/");
			String rootPath=root.substring(0, root.lastIndexOf("\\"));
			String realRootPath=rootPath.substring(0, rootPath.lastIndexOf("\\"));
			String savePath =realRootPath+ "\\attached\\template.xls";
			ArrayList<School> list=ExcelUtil.getDataByExcel(savePath);
			SchoolDao sd=new SchoolImpl();
			for(School school:list){
				if(sd.findByName(school.getName())!=null){
					sd.update(school);
				}else{
					sd.addSchool(school);
				}
			}
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}*/else if("delete".equals(method)){//4,清空学校
			System.out.println("study....delete....");
			SchoolDao sd=new SchoolImpl();
			sd.deleteAll();
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("list-mid".equals(method)){//5.中学列表
			System.out.println("study....list-mid.....");
			int page=Integer.valueOf(request.getParameter("page"));
			int rows=Integer.valueOf(request.getParameter("rows"));
			int offset=(page-1)*rows;
			int total=0;
			SchoolDao sd=new SchoolImpl();
			ArrayList<School> list=sd.findAll2(offset, rows);
			total=sd.findAll2();
			JSONObject json=new JSONObject();
			json.element("rows", list);
			json.element("total", total);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}else if("add-mid".equals(method)){//6,批量添加中学
			System.out.println("study....add-mid.....");
			String root = this.getServletContext().getRealPath("/");
			String rootPath=root.substring(0, root.lastIndexOf("\\"));
			String realRootPath=rootPath.substring(0, rootPath.lastIndexOf("\\"));
			String savePath =realRootPath+ "\\attached\\midschool-template.xls";
			ArrayList<School> list=ExcelUtil.getDataByExcel2(savePath);
			SchoolDao sd=new SchoolImpl();
			for(School school:list){
				if(sd.findByName2(school.getName())!=null){
					sd.update2(school);
				}else{
					sd.addSchool2(school);
				}
			}
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("delete-mid".equals(method)){//7,批量添加中学
			System.out.println("study....delete-mid....");
			SchoolDao sd=new SchoolImpl();
			sd.deleteAll2();
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("publishstep".equals(method)){//发布申请流程
			System.out.println("study....publishstep.....");
			String content=request.getParameter("content");
			ApplyStep applystep=new ApplyStep();
			applystep.setContent(content);
			ApplyStepDao as=new ApplyStepImpl();
			if(as.find()!=null){
				as.update(applystep);
			}else{
				as.add(applystep);
			}
			JSONObject json=new JSONObject();
			json.element("success", true);
			json.element("content", content);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("applylist".equals(method)){//显示流程内容
			System.out.println("study...applylist.....");
			ApplyStepDao ad=new ApplyStepImpl();
			ApplyStep applystep=ad.find();
			if(applystep!=null){
				JSONObject json=new JSONObject();
				json.element("success", true);
				json.element("content", applystep.getContent());
				PrintWriter out=response.getWriter();
				out.write(json.toString());
			}
			return;
		}else if("deleteapply".equals(method)){//删除申请流程
			System.out.println("study....deleteapply....");
			ApplyStepDao ad=new ApplyStepImpl();
			ad.delete();
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("publishstep".equals(method)){//发布申请流程
			System.out.println("study....publishstep.....");
			String content=request.getParameter("content");
			ApplyStep applystep=new ApplyStep();
			applystep.setContent(content);
			ApplyStepDao as=new ApplyStepImpl();
			if(as.find()!=null){
				as.update(applystep);
			}else{
				as.add(applystep);
			}
			JSONObject json=new JSONObject();
			json.element("success", true);
			json.element("content", content);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("applylist".equals(method)){//显示流程内容
			System.out.println("study...applylist.....");
			ApplyStepDao ad=new ApplyStepImpl();
			ApplyStep applystep=ad.find();
			if(applystep!=null){
				JSONObject json=new JSONObject();
				json.element("success", true);
				json.element("content", applystep.getContent());
				PrintWriter out=response.getWriter();
				out.write(json.toString());
			}
			return;
		}else if("deleteapply".equals(method)){//删除申请流程
			System.out.println("study....deleteapply....");
			ApplyStepDao ad=new ApplyStepImpl();
			ad.delete();
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("publishmetrial".equals(method)){//发布更新材料
			System.out.println("study....publisgmetrial.....");
			String content=request.getParameter("content");
			Visa visa=new Visa();
			visa.setContent(content);
			VisaDao vd=new VisaImpl();
			if(vd.find()!=null){
				vd.update(visa);
			}else{
				vd.add(visa);
			}
			JSONObject json=new JSONObject();
			json.element("success", true);
			json.element("content", content);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("metriallist".equals(method)){//显示材料内容
			System.out.println("study...metriallist.....");
			VisaDao vd=new VisaImpl();
			Visa visa=vd.find();
			if(visa!=null){
				JSONObject json=new JSONObject();
				json.element("success", true);
				json.element("content", visa.getContent());
				PrintWriter out=response.getWriter();
				out.write(json.toString());
			}
			return;
		}else if("deletemetrial".equals(method)){//删除材料
			System.out.println("study....deletemet....");
			VisaDao vd=new VisaImpl();
			vd.delete();
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("listpartjob".equals(method)){//兼职列表
			System.out.println("study....listpartjob.....");
			int page=Integer.valueOf(request.getParameter("page"));
			int rows=Integer.valueOf(request.getParameter("rows"));
			int offset=(page-1)*rows;
			int total=0;
			PartJobDao ptd=new PartJobImpl();
			ArrayList<PartJob> list=ptd.findAll(offset, rows);
			total=ptd.findAll();
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			JSONObject json=new JSONObject();
		    json.element("rows", JSONArray.fromObject(list,jsonConfig));
		    json.element("total", total);
		    PrintWriter out=response.getWriter();
		    out.write(json.toString());
		    System.out.println(json.toString());
		    return;
			
		}else if("addpartjob".equals(method)){
			System.out.println("study....addpartjob......");
			String title=request.getParameter("title");
			String content=request.getParameter("content");
			PartJob partjob=new PartJob();
			partjob.setTitle(title);
			partjob.setContent(content);
			PartJobDao ptd=new PartJobImpl();
			ptd.add(partjob);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("editpartjob".equals(method)){
			System.out.println("study...editpartjob.......");
			String id=request.getParameter("id");
			String title=request.getParameter("title");
			String content=request.getParameter("content");
			PartJob ptj=new PartJob();
			ptj.setId(Integer.valueOf(id));
			ptj.setTitle(title);
			ptj.setContent(content);
			PartJobDao ptd=new PartJobImpl();
			ptd.update(ptj);
			JSONObject json=new JSONObject();
			json.element("success",true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("deletepartjob".equals(method)){
			System.out.println("study.....deletepartjob......");
			String id=request.getParameter("id");
			PartJobDao ptd=new PartJobImpl();
			ptd.delete(Integer.valueOf(id));
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("liststudy".equals(method)){
			System.out.println("study....liststudy.....");
			int page=Integer.valueOf(request.getParameter("page"));
			int rows=Integer.valueOf(request.getParameter("rows"));
			int offset=(page-1)*rows;
			int total=0;
			StudyDao sd=new StudyImpl();
			ArrayList<Study> list=sd.findAll(offset, rows);
			total=sd.findAll();
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			JSONObject json=new JSONObject();
		    json.element("rows", JSONArray.fromObject(list,jsonConfig));
		    json.element("total", total);
		    PrintWriter out=response.getWriter();
		    out.write(json.toString());
		    System.out.println(json.toString());
		    return;
			
		}else if("addstudy".equals(method)){
			System.out.println("study....addstudy......");
			String title=request.getParameter("title");
			String content=request.getParameter("content");
			Study study=new Study();
			study.setTitle(title);
			study.setContent(content);
			StudyDao sd=new StudyImpl();
			sd.add(study);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("editstudy".equals(method)){
			System.out.println("study...editstudy.......");
			String id=request.getParameter("id");
			String title=request.getParameter("title");
			String content=request.getParameter("content");
			Study s=new Study();
			s.setId(Integer.valueOf(id));
			s.setTitle(title);
			s.setContent(content);
			StudyDao sd=new StudyImpl();
			sd.update(s);
			JSONObject json=new JSONObject();
			json.element("success",true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("deletestudy".equals(method)){
			System.out.println("study.....deletepartjob......");
			String id=request.getParameter("id");
			StudyDao sd=new StudyImpl();
			sd.delete(Integer.valueOf(id));
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("item".equals(method)){
			System.out.println("item........");
			String id=request.getParameter("id");
			Study study=new Study();
			StudyDao sd=new StudyImpl();
			study=sd.findById(Integer.valueOf(id));
			System.out.println(study.getContent());
			if(study!=null){
				request.setAttribute("obj",study);
			}
			request.getRequestDispatcher("/WEB-INF/page/admin/dashboard-item.jsp").forward(request, response);
		}else if("addcollege".equals(method)){//添加大学
			System.out.println("study....addcollege......");
			String name=request.getParameter("name");
			String content=request.getParameter("content");
			int rank=Integer.valueOf(request.getParameter("rank"));
			System.out.println(name);
			System.out.println(content);
			System.out.println(rank);
			School school=new School();
			school.setName(name);
			school.setContent(content);
			school.setRank(rank);
			SchoolDao sd=new SchoolImpl();
			ArrayList<String[]> list=sd.findAllMajor();
			sd.addSchool(school,list);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("deletecollege".equals(method)){
			System.out.println("study....deletecollege....");
			int id=Integer.valueOf(request.getParameter("id"));
			SchoolDao sd=new SchoolImpl();
			sd.deleteCollege(id);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("editcollege".equals(method)){
			System.out.println("study....editcollege....");
			String name=request.getParameter("name");
			String content=request.getParameter("content");
			int rank=Integer.valueOf(request.getParameter("rank"));
			int id=Integer.valueOf(request.getParameter("id"));
			School school=new School();
			school.setId(id);
			school.setName(name);
			school.setContent(content);
			school.setRank(rank);
			SchoolDao sd=new SchoolImpl();
			sd.updateCollege(school);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("updaterank".equals(method)){
			System.out.println("study....updaterank...");
			int id=Integer.valueOf(request.getParameter("id"));
			String fieldname=request.getParameter("fieldname");
			String value=request.getParameter("value");
			System.out.println(id);
			System.out.println(value);
			System.out.println(fieldname);
			SchoolDao sd=new SchoolImpl();
			if("学校排名".equals(fieldname)){//更新school表
				sd.updateRank(id, Integer.valueOf(value));
				
			}else{//更新school_maor表
				sd.updateMajorRank(id, fieldname, value);
			}
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("addmajor".equals(method)){//增加专业
			System.out.println("study....addmajor....");
			String name=request.getParameter("name");
			System.out.println(name+"...name");
			SchoolDao sd=new SchoolImpl();
			ArrayList<School> list=sd.findAllSchool();
			int[] count=sd.addMajor(name, list);
			JSONObject json=new JSONObject();
			if(count!=null){
				json.element("success", true);
			}else{
				json.element("success", false);
			}
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("majors".equals(method)){//专业列表
			System.out.println("study...majors....");
			SchoolDao sd=new SchoolImpl();
			ArrayList<String[]> list=sd.findAllMajor();
			JSONObject json=new JSONObject();
			if(list!=null){
				json.element("majors", list);
				json.element("length", list.size());
			}
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
			
		}else if("rank".equals(method)){//各专业排名
			System.out.println("study....rank......");
			String fieldname=request.getParameter("fieldname");
			int page=Integer.valueOf(request.getParameter("page"));
			int rows=Integer.valueOf(request.getParameter("rows"));
			int offset=(page-1)*rows;
			int total=0;
			SchoolDao sd=new SchoolImpl();
			ArrayList<School> list=sd.getMajorRank(fieldname, offset, rows);
			total=sd.findAll();
			JSONObject json=new JSONObject();
			json.element("rows", list);
			json.element("total", total);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}else if("majorname".equals(method)){//修改专业的名字
			System.out.println("study...majorname......");
			String oldname=request.getParameter("oldname");
			String newname=request.getParameter("newname");
			System.out.println(oldname);
			System.out.println(newname);
			JSONObject json=new JSONObject();
			SchoolDao sd=new SchoolImpl();
			if(sd.updateMajorName(oldname, newname)>0){
				json.element("success", true);
			}else{
				json.element("success", false);
			}
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
			
		}else if("deletemajor".equals(method)){
			System.out.println("study....deletemajor....");
			String name=request.getParameter("name");
			System.out.println(name);
			JSONObject json=new JSONObject();
			SchoolDao sd=new SchoolImpl();
			if(sd.deleteMajor(name)>0){
				json.element("success", true);
			}else{
				json.element("success", false);
			}
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
			
		}else if("addmid".equals(method)){//添加中学
			String name=request.getParameter("name");
			String content=request.getParameter("content");
			School school=new School();
			school.setName(name);
			school.setContent(content);
			SchoolDao sd=new SchoolImpl();
			sd.addSchool2(school);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;

		}else if("editmid".equals(method)){//编辑中学
			Integer id=Integer.valueOf(request.getParameter("id"));
			String name=request.getParameter("name");
			String content=request.getParameter("content");
			School school=new School();
			school.setName(name);
			school.setContent(content);
			school.setId(id);
			SchoolDao sd=new SchoolImpl();
			sd.updateMidschool(school);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
			
		}else if("deletemid".equals(method)){
			Integer id=Integer.valueOf(request.getParameter("id"));
			SchoolDao sd=new SchoolImpl();
			sd.deleteMidschool(id);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}else if("data".equals(method)){//大学列表
			response.setContentType("application/json;charset=utf-8");
			SchoolDao sd=new SchoolImpl();
			ArrayList<School> list=sd.getAllData();
			JSONObject json=new JSONObject();
			json.element("data", list);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}else if("info".equals(method)){//大学详情
			int id=Integer.valueOf(request.getParameter("id"));
			SchoolDao sd=new SchoolImpl();
            String str=sd.getSchoolContent(id);
            JSONObject json=new JSONObject();
            json.element("str", str);
            PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
            
		}else if("majorrank".equals(method)){//手机端大学专业排名
			String fieldname=URLDecoder.decode(request.getQueryString(),"UTF-8");
			System.out.println("study.....majorrank....."+fieldname.split("&")[1].split("=")[1]);
			SchoolDao sd=new SchoolImpl();
			ArrayList<School> list=sd.majorRank(fieldname.split("&")[1].split("=")[1]);
			JSONObject json=new JSONObject();
			json.element("schools", list);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}else if("data-school".equals(method)){//手机端中学列表
			SchoolDao sd=new SchoolImpl();
			ArrayList<School> list=sd.getMidschool();
			JSONObject json=new JSONObject();
			json.element("schools", list);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
			
		}else if("midinfo".equals(method)){//手机端中学详情
			int id=Integer.valueOf(request.getParameter("id"));
			SchoolDao sd=new SchoolImpl();
            String str=sd.getMidSchoolContent(id);
            JSONObject json=new JSONObject();
            json.element("str", str);
            PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("jobs".equals(method)){//手机端兼职列表
			PartJobDao pjd=new PartJobImpl();
			ArrayList<PartJob> jobs=pjd.getJobs();
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			JSONObject json=new JSONObject();
		    json.element("jobs", JSONArray.fromObject(jobs,jsonConfig));
		    PrintWriter out=response.getWriter();
		    out.write(json.toString());
		    System.out.println(json.toString());
		    return;
		}else if("jobinfo".equals(method)){//手机端兼职详情
			int id=Integer.valueOf(request.getParameter("id"));
			PartJobDao pjd=new PartJobImpl();
			String content=pjd.getContent(id);
			JSONObject json=new JSONObject();
		    json.element("content", content);
		    PrintWriter out=response.getWriter();
		    out.write(json.toString());
		    System.out.println(json.toString());
		    return;
		}
		else if("mobile".equals(method)){
			String page=request.getParameter("page");
			if("mobilepage".equals(page)){
				System.out.println("study...mobile....mobilepage.....");
				request.getRequestDispatcher("/WEB-INF/page/user/3.jsp").forward(request, response);
			}else if("collegeinfo".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/collegeinfo.jsp").forward(request, response);
			}else if("collegerank".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/collegerank.jsp").forward(request, response);

			}else if("majorrank".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/majorrank.jsp").forward(request, response);

			}else if("commerce".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/commerce.jsp").forward(request, response);

			}else if("art".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/art.jsp").forward(request, response);

			}else if("engining".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/engining.jsp").forward(request, response);

			}else if("science".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/science.jsp").forward(request, response);

			}else if("language".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/language.jsp").forward(request, response);
			}else if("middle".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/mid-school.jsp").forward(request, response);

			}else if("apply".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/applystep.jsp").forward(request, response);

			}else if("visa".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/visadetail.jsp").forward(request, response);

			}else if("partjob".equals(page)){
				request.getRequestDispatcher("/WEB-INF/page/user/partjob.jsp").forward(request, response);

			}else if("middinfo".equals(page)){//中学信息详情
				request.getRequestDispatcher("/WEB-INF/page/user/middschinfo.jsp").forward(request, response);
			}
		}
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
